<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录</title>
<script type="text/javascript">
/*账号确认*/
function judge1(){
		var user=document.getElementById("user");
		var text=document.getElementById("text");
		text.style.display="none";
	}
function judge2(){
	var user=document.getElementById("user");
	var text=document.getElementById("text");
		if(user.value==""){
			text.style.display="block";
		}else{
			text.style.display="none";
		}
		
	}
	
/*输入密码确认*/
function judge3(){
		var psw=document.getElementById("psw");
		var text3=document.getElementById("text3");
		var text4=document.getElementById("text4");
		text3.style.display="none";
		text4.style.display="none";
	}
function judge4(){
	var psw=document.getElementById("psw").value;
	var text3=document.getElementById("text3");
	var text4=document.getElementById("text4");
		if(psw==""){
			text3.style.display="block";
			text4.style.display="none";
		}else if(psw.length<6||psw.length>10){
			text3.style.display="none";
			text4.style.display="block";
		}else{
			text3.style.display="none";
			text4.style.display="none";
		}
	}
	
function send(){
	document.getElementById("form").action="${pageContext.request.contextPath}/users/add.jsp"	
}
function send2(){
	document.getElementById("form").action="${pageContext.request.contextPath}/MessageServlet"	
	document.getElementById("show").submit();
}
</script>
<c:remove var="MessageType" scope="session"/>
<c:remove var="MessageName" scope="session"/>
</head>
<body>
<div style=" height:300px; line-height:50px" align="center">
	<form action="${pageContext.request.contextPath}/UsersServlet" method="post" id="form" name="form">
	<table width="600px">
	  	<td colspan="2" align="right"><h1>用户登录</h1></td>
	  <tr>
	    <td align="right">用户名：</td>
	    <td width="150px" align="left"><input name="username" type="text" value="q1" id="user" onfocus="judge1(this)" onblur="judge2(this)"/></td>
	    <td width="270px" align="left"><em id="text" style="display:none;">账号不能为空</em></td>
	  </tr>
	  <tr>
	    <td align="right">密码：</td>
	    <td width="150px" align="left"><input name="password" type="password" value="qqqqqq" id="psw" onfocus="judge3(this)" onblur="judge4(this)"/></td>
	    <td align="left"><em id="text3" style="display:none;">密码不能为空！</em>
			<em id="text4" style="display:none;">密码不能少于六位且不能大于十位！</em></td>
	  </tr>
	  <tr>
	    <td align="right" colspan="2"><input name="submittype" type="submit" value="登录"/>&nbsp;&nbsp;&nbsp;&nbsp;
		<input name="submittype" type="submit" value="注册" onclick="send()"/>
		</td>
	    <td align="left">&nbsp;&nbsp;&nbsp;&nbsp;<input name="submittype" id="show" type="submit" value="游客查看留言" onclick="send2()"/></td>
	  </tr>
	    <td colspan="2" align="right">${error}</td>
	</table>
	</form>
</div>
</body>
</html>